// $Id: PluginSettingsEditor.cs 64 2008-05-06 18:29:47Z nvivo $

using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace DBLGen.UI
{
    public class PluginSettingsEditor : UserControl
    {
        [Category("Plugin Settings")]
        [Description("Occours after the settings had been loaded into the editor.")]
        public event EventHandler LoadingSettings;
        
        [Category("Plugin Settings")]
        [Description("Occours before the settings is sent back to the application.")]
        public event EventHandler SavingSettings;

        private PluginSettings _settings;

        protected PluginSettings Settings
        {
            get
            {
                return _settings;
            }
            set
            {
                _settings = value;
            }
        }

        public void LoadSettings(PluginSettings settings)
        {
            _settings = settings.Clone();

            if (LoadingSettings != null)
                LoadingSettings(this, EventArgs.Empty);
        }

        public PluginSettings SaveSettings()
        {
            if (SavingSettings != null)
                SavingSettings(this, EventArgs.Empty);

            return _settings.Clone();
        }
    }
}
